/* eslint-disable import/no-duplicates */
import 'babel-polyfill' // 解决es6语法的兼容问题，引入此库
import promise from 'es6-promise' // 解决es6-promise不兼容
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/icon/iconfont.css'
import './assets/css/global.css'
import echarts from 'echarts'

// bpmn 相关依赖
import 'bpmn-js/dist/assets/diagram-js.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'

// 左边工具栏以及编辑节点的样式
import 'bpmn-js-properties-panel/dist/assets/bpmn-js-properties-panel.css'
import 'element-ui/lib/theme-chalk/index.css'
// 使用插件形式导入请求
// eslint-disable-next-line import/no-duplicates
import { postRequest } from './utils/api'
// eslint-disable-next-line import/no-duplicates
import { putRequest } from './utils/api'
import { getRequest } from './utils/api'
import { deleteRequest } from './utils/api'
import { downloadRequest } from './utils/download' // 解决promise问题
promise.polyfill()
Vue.config.productionTip = false

Vue.use(ElementUI)

// 使用插件形式使用请求
Vue.prototype.postRequest = postRequest
Vue.prototype.putRequest = putRequest
Vue.prototype.getRequest = getRequest
Vue.prototype.deleteRequest = deleteRequest
Vue.prototype.downloadRequest = downloadRequest
Vue.prototype.$echarts = echarts

// 路由守卫
router.beforeEach((to, from, next) => {
  if (to.name !== '登录' && !window.sessionStorage.getItem('tokenStr')) {
    next({ name: '登录' })
  } else next()
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
